<!DOCTYPE HTML>
<html>
<head>
<style>
* { display:block; }
.collapse { visibility:collapse; }
</style>
<script>

if (window.testRunner) {
  testRunner.dumpAsText();
  testRunner.waitUntilDone();
}

document.designMode = "on";
var scriptElements = document.getElementsByTagName("script");
scriptElements[0].parentNode.removeChild(scriptElements[0]);
var eventHandlerActive = false;

function event_handler_webkitEditableContentChanged() {
  if (eventHandlerActive)
    return;
  eventHandlerActive = true;
  var srcElement = event.srcElement;
  document.execCommand('InsertText',false,'dummy text');
  srcElement.textContent = "Pass. Test didn't crash.";
  eventHandlerActive = false;
  if (window.testRunner)
    testRunner.notifyDone();
}

document.addEventListener("input", event_handler_webkitEditableContentChanged, true);

function event_handler_DOMCharacterDataModified() {
  document.execCommand('InsertParagraph',false,false);
}

document.addEventListener("DOMCharacterDataModified", event_handler_DOMCharacterDataModified, false);

window.addEventListener("load", function() {
  var selection=window.getSelection();
  document.execCommand("SelectAll", false)
  var range = selection.getRangeAt(0);
  var documentFragment = range.extractContents();
  document.execCommand('Undo',false);
});
</script>
</head>
<body>
<table class="collapse">
<caption>
original text
</caption>
</table>
</body>
</html>
